package 实训训练;

public class demo2 {


    public static void main(String[] args) {
        int a=4;
       System.out.println(dg(a));
        System.out.println(dgjia(a));
        System.out.println(ddfeibo(10));
        System.out.println(dgfeibo(10));
    }
    public static int dg(int a){
        int aa=1;
        if (a!=0){
            aa=a*dg(a-1);
        }
        return aa;
    }
    public static int dgjia(int a){
        int aa=0;
        if (aa<=a){
            aa=a+dgjia(a-1);
        }
        return aa;
    }
    public static int ddfeibo(int num) {
        if (num <= 0) {
            return 0;
        }
        if (num == 1 || num == 2) {
            return 1;
        }
        int first = 1, second = 1, third = 0;
        for (int i = 3; i <= num; i++) {
            third = first + second;
            first = second;
            second = third;
        }
        return third;
    }
    public static int dgfeibo(int a){
        if (a <= 0) {
            return 0;
        }
        if (a == 1 || a == 2) {
            return 1;
        }

        return dgfeibo(a-2)+dgfeibo(a-1);
    }
}
